import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import path from "path";
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' //svg配置
export default defineConfig({
  plugins: [
    vue(),
    // elementplus按需引入
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    // svg插件配置
    createSvgIconsPlugin({
      iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
      symbolId: 'icon-[dir]-[name]',
    }),
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  // 配置全局scss变量
  css: {
    // css预处理器
    preprocessorOptions: {
      scss: {
        // 定义全局的scss变量
        // 给导入的路径最后加上 ;
        additionalData: `@import '@/assets/styles/variable.scss';`,
      },
    },
  },
  server:{
    // proxy:{
    //   // '/dev-api':{
    //   //   target:"http://localhost",
    //   //   rewrite:(path)=>path.replace(/^\/dev-api/,''),
    //   // },
    //   '/api':{
    //     target:"http://121.41.107.43:8888",
    //     rewrite:(path)=>path.replace(/^\/api/,''),
    //   }
      
    // }
  }
});
